#ifndef DBSQLITE_H
#define DBSQLITE_H

#include "db.h"

#define SQLITE3_CREATE_TABLE_BANS			"CREATE TABLE IF NOT EXISTS bans"										\
											"("																		\
												"id INTEGER PRIMARY KEY,"											\
												"server TEXT NOT NULL,"												\
												"name TEXT NOT NULL,"												\
												"ip TEXT,"															\
												"date TEXT NOT NULL,"												\
												"gamename TEXT,"													\
												"banner TEXT NOT NULL,"												\
												"reason TEXT,"														\
												"gamecount INTEGER,"												\
												"expiredate TEXT NOT NULL"											\
											")"

#define SQLITE3_CREATE_TABLE_CONFIG			"CREATE TABLE IF NOT EXISTS config"										\
											"("																		\
												"name TEXT NOT NULL PRIMARY KEY,"									\
												"version TEXT NOT NULL"												\
											")"

#define SQLITE3_CREATE_TABLE_DOTAGAMES		"CREATE TABLE IF NOT EXISTS dotagames"									\
											"("																		\
												"id INTEGER PRIMARY KEY,"											\
												"gameid INTEGER NOT NULL,"											\
												"winner INTEGER NOT NULL,"											\
												"min INTEGER NOT NULL,"												\
												"sec INTEGER NOT NULL"												\
											")"

#define SQLITE3_CREATE_TABLE_DOTAPLAYERS	"CREATE TABLE IF NOT EXISTS dotaplayers"								\
											"("																		\
												"id INTEGER PRIMARY KEY,"											\
												"gameid INTEGER NOT NULL,"											\
												"color INTEGER NOT NULL,"											\
												"kills INTEGER NOT NULL,"											\
												"deaths INTEGER NOT NULL,"											\
												"creepkills INTEGER NOT NULL,"										\
												"creepdenies INTEGER NOT NULL,"										\
												"assists INTEGER NOT NULL,"											\
												"gold INTEGER NOT NULL,"											\
												"neutralkills INTEGER NOT NULL,"									\
												"item1 TEXT NOT NULL,"												\
												"item2 TEXT NOT NULL,"												\
												"item3 TEXT NOT NULL,"												\
												"item4 TEXT NOT NULL,"												\
												"item5 TEXT NOT NULL,"												\
												"item6 TEXT NOT NULL,"												\
												"hero TEXT NOT NULL,"												\
												"newcolor NOT NULL,"												\
												"towerkills NOT NULL,"												\
												"raxkills NOT NULL,"												\
												"courierkills NOT NULL,"											\
												"apm INTEGER NOT NULL"												\
											")"

#define SQLITE3_CREATE_TABLE_GAMEPLAYERS	"CREATE TABLE IF NOT EXISTS gameplayers"								\
											"("																		\
												"id INTEGER PRIMARY KEY,"											\
												"gameid INTEGER NOT NULL,"											\
												"server TEXT NOT NULL,"												\
												"name TEXT NOT NULL,"												\
												"ip TEXT NOT NULL,"													\
												"spoofed INTEGER NOT NULL,"											\
												"reserved INTEGER NOT NULL,"										\
												"loadingtime INTEGER NOT NULL,"										\
												"left INTEGER NOT NULL,"											\
												"leftreason TEXT NOT NULL,"											\
												"team INTEGER NOT NULL,"											\
												"color INTEGER NOT NULL"											\
											")"

#define SQLITE3_CREATE_TABLE_GAMES			"CREATE TABLE IF NOT EXISTS games"										\
											"("																		\
												"id INTEGER PRIMARY KEY,"											\
												"server TEXT NOT NULL,"												\
												"map TEXT NOT NULL,"												\
												"datetime TEXT NOT NULL,"											\
												"gamename TEXT NOT NULL,"											\
												"ownername TEXT NOT NULL,"											\
												"duration INTEGER NOT NULL,"										\
												"gamestate INTEGER NOT NULL,"										\
												"creatorname TEXT NOT NULL,"										\
												"creatorserver TEXT NOT NULL"										\
											")"

#define SQLITE3_CREATE_TABLE_SCORES			"CREATE TABLE IF NOT EXISTS scores"										\
											"("																		\
												"id INTEGER PRIMARY KEY,"											\
												"category TEXT NOT NULL,"											\
												"name TEXT NOT NULL,"												\
												"server TEXT NOT NULL,"												\
												"score REAL NOT NULL"												\
											")"


#define SQLITE3_CREATE_TABLE_USERS			"CREATE TABLE IF NOT EXISTS users"										\
											"("																		\
												"id INTEGER PRIMARY KEY,"											\
												"server TEXT NOT NULL,"												\
												"name TEXT NOT NULL,"												\
												"voucher TEXT NOT NULL,"											\
												"access INT64 NOT NULL"												\
											")"

#define SQLITE3_CREATE_TABLE_W3MMDPLAYERS	"CREATE TABLE IF NOT EXISTS w3mmdplayers"								\
											"("																		\
												"id INTEGER PRIMARY KEY,"											\
												"category TEXT NOT NULL,"											\
												"gameid INTEGER NOT NULL,"											\
												"pid INTEGER NOT NULL,"												\
												"name TEXT NOT NULL,"												\
												"flag TEXT NOT NULL,"												\
												"leaver INTEGER NOT NULL,"											\
												"practicing INTEGER NOT NULL"										\
											")"	

#define SQLITE3_CREATE_TABLE_W3MMDVARS		"CREATE TABLE IF NOT EXISTS w3mmdvars"									\
											"("																		\
												"id INTEGER PRIMARY KEY,"											\
												"gameid INTEGER NOT NULL,"											\
												"pid INTEGER NOT NULL,"												\
												"varname TEXT NOT NULL,"											\
												"value_int INTEGER DEFAULT NULL,"									\
												"value_real REAL DEFAULT NULL,"										\
												"value_string TEXT DEFAULT NULL"									\
											")"																	

#define SQLITE_CURRENT_HBOT_SCHEME_VERSION "0"

class CDBSQLite: public CDatabase
{
private:
	QString m_File;

public:
	CDBSQLite(const QString &file);
	virtual ~CDBSQLite();

	virtual QString GetFileName() const															{ return m_File; }
};

#endif // DBSQLITE_H
